/*
 * @Author: leemr lscmr@qq.com
 * @Date: 2023-12-11 17:49:22
 * @LastEditors: leemr lscmr@qq.com
 * @LastEditTime: 2023-12-21 16:33:37
 * @FilePath: \futures-bill\src\apis\index.ts
 * @Description:api接口
 *
 */

import { get, jsonpHttp, logPost, post } from '~/utils/request'
import { API, ENV, PASS, PROTOOL, SECRET, SHAREHREF } from '~/config'

export function getShare(url = SHAREHREF): Promise<any> {
  return post(`${PROTOOL}//api.hatzjh.com/weixin/wxshare`, { url })
}

export function getBrowserId(data: any): Promise<any> {
  return logPost(`${API}mobiles/monitor/index`, data)
}

export function getToken(): Promise<any> {
  return new Promise((resolve, reject): any => {
    if (ENV.PROD) {
      jsonpHttp(`${PASS}userlogin/iflogin?`, {
        state: 0,
        secret: SECRET,
      })
        .then((data) => {
          resolve([null, data])
        })
        .catch((err) => {
          resolve([err, null])
        })
    }
    else {
      get('/userlogin/iflogin?state=0&secret=tzjh2019')
        .then((data) => {
          resolve(data)
        })
        .catch((err) => {
          reject(err)
        })
    }
  })
}
